package com.demo.service.impl;

import com.demo.dao.DeveloperDao;
import com.demo.pojo.Developer;
import com.demo.service.DeveloperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName DeveloperServieImpl
 * @Description TODO
 * @Author Windy
 * @Date 2022/9/2 14:56
 * @Version 1.0
 **/
@Service
//@Transactional
public class DeveloperServiceImpl implements DeveloperService {
    @Autowired
    DeveloperDao developerDao;
    @Override
    public List<Developer> findAll() {
        return developerDao.findAll();
    }

    @Override
    public Developer findDeveloperById(String id) {
        return developerDao.findDeveloperById(id);
    }

    @Override
    public Developer findDeveloperByName(String name) {
        return developerDao.findDeveloperByName(name);
    }

    @Override
    public boolean deletedDeveloper(Developer developer) {
        int i = developerDao.deletedDeveloper(developer);
        if (i > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean updateDeveloperById(Developer developer) {
        int i = developerDao.updateDeveloperById(developer);
//        int a=1/0;
        return i>=0;
    }

    @Override
    public boolean insertDeveloper(Developer developer) {
        return developerDao.insertDeveloper(developer) >= 0;
    }
}
